<%@page import="cn.com.xf.common.StringUtil"%>
<%@page import="java.math.BigDecimal"%>
<%@page import="org.apache.commons.lang.StringUtils"%>
<%@page import="org.apache.commons.lang.time.DateFormatUtils"%>
<%@page import="org.springframework.util.CollectionUtils"%>
<%@page import="java.util.Collection"%>
<%@ include file="../common/common_include.jsp"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%
	SettingForm form = (SettingForm)request.getAttribute("command");
	TblOaAuthRole role = (TblOaAuthRole)request.getAttribute("role");
	List<BigDecimal> permissionIdList = new ArrayList<BigDecimal>();
	if(null!=role){
		if(StringUtils.isNotBlank(role.getPermissionIds())){
			String permissionIdArr[] = role.getPermissionIds().split(",");
			for(String r:permissionIdArr){
				if (StringUtil.isNumeric(r)) {
					permissionIdList.add(new BigDecimal(r));
				}
			}
		}
	}
	List<TblOaAuthPermission> permissionlist = (List<TblOaAuthPermission> )request.getAttribute("permissionlist");
%>


<div>
	<form id="roleEditForm" target="_coreIframe"
		action="<%=request.getContextPath()%>/setting/doEditRole">
		<div class="breadcrumb">
			<div class="bcIcon"></div>
			<ul class="bcNav">
				<li>编辑角色</li>
			</ul>
		</div>
		<input type="hidden" value="<%=EncrypTool.encode(role.getRoleId()+"")%>" name="roleId">
		<table class="formTable">
			<tr>
				<td class="tdTitle">角色名称:</td>
				<td><input class="inputText xs" value="<%=role.getRoleDesc()%>" name="roleDesc"></td>
			</tr>
			<tr>
				<td class="tdTitle">权限：</td>
				<td class="" colspan="2">
					<div style="padding-top:10px;padding-bottom:10px;">
						<div class="checkbox-wrap">
							<label>
								<input type="checkbox" class="checkbox checkboxSelectAll">
								<span>全选</span>
							</label>
						</div>
						<div class="checkbox-wrap">
						<%
							if(!CollectionUtils.isEmpty(permissionlist)){
								for(TblOaAuthPermission p :permissionlist){
									%>
										<label class="check-label-role" style="display:block; width:20%;">
											<input type="checkbox"
											 value="<%=EncrypTool.encode(p.getPermissionId()+"")%>" 
											 name="permissioins" 
											 class="checkbox"
											 <%=permissionIdList.contains(p.getPermissionId())?"checked='checked'":""%>
											 >
											<span><%=p.getPermissionName() %></span>
										</label>
									<%
								}
							}
						%>
						</div>
					</div>
				</td>
			</tr>
			<tr>
				<td class="tdTitle"></td>
				<td>
					<div>
						<input class="input-btn-microsoft" type="submit" value="提交">
						<a class="a-btn-microsoft" href="javascript:XF.Setting.listRole()">取消</a>
					</div>
				</td>
			</tr>	
		</table>
	</form>
	<iframe id="_coreIframe" name="_coreIframe" style="display: none;"></iframe>
</div>
<script>
	XF.Setting.initAddRole();
</script>









